@echo off
chcp 65001 >nul
cls
echo ====================================
echo 梦幻西游数字资产管理系统
echo ====================================
echo.

:: 检查Python是否安装
python --version >nul 2>&1
if errorlevel 1 (
    echo [错误] 未检测到Python，请先安装Python 3.7+
    echo 下载地址: https://www.python.org/downloads/
    pause
    exit /b 1
)

echo [1/3] 检测Python环境... OK
echo.

:: 自动安装依赖包
echo [2/3] 安装/检查依赖包...
python -m pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
if errorlevel 1 (
    echo [警告] 阿里云镜像失败，尝试清华镜像...
    python -m pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
    if errorlevel 1 (
        echo [警告] 清华镜像失败，尝试使用默认源...
        python -m pip install -r requirements.txt
        if errorlevel 1 (
            echo [错误] 依赖安装失败，请检查网络连接
            pause
            exit /b 1
        )
    )
)
echo 依赖包准备完成！
echo.

echo [3/3] 启动系统...
echo.
echo ====================================
echo 系统已启动！
echo 访问地址: http://127.0.0.1:5000
echo 按 Ctrl+C 可以停止服务器
echo ====================================
echo.

:: 启动Flask应用
python app.py

pause

